//
//  BCDataview.m
//  BangcaiSale
//
//  Created by lsy on 16/7/9.
//  Copyright © 2016年 Bangcai. All rights reserved.
//

#import "BCDataview.h"

@interface BCDataview ()
{
    UILabel *time;
    
    
    UILabel *lab0;
    UILabel *lab1;
    UILabel *lab2;
    UILabel *lab3;
    UILabel *lab4;
    UILabel *lab5;
    UILabel *lab6;
    UILabel *line;
    
    UILabel *week0;
    UILabel *week1;
    UILabel *week2;
    UILabel *week3;
    UILabel *week4;
    UILabel *week5;
    UILabel *week6;

    
}
@end

@implementation BCDataview
- (void)createView
{
    time = [[UILabel alloc] init];
    time.font = [UIFont systemFontOfSize:14];
    time.textColor = [UIColor colorWithRed:0.698  green:0.698  blue:0.706 alpha:1];
    
    lab0 = [[UILabel alloc] init];
    lab1 = [[UILabel alloc] init];
    lab2 = [[UILabel alloc] init];
    lab3 = [[UILabel alloc] init];
    lab4 = [[UILabel alloc] init];
    lab5 = [[UILabel alloc] init];
    lab6 = [[UILabel alloc] init];
    
    week0 = [[UILabel alloc] init];
    week0.textColor = [UIColor colorWithRed:0.612  green:0.616  blue:0.616 alpha:1];
    week0.font = [UIFont systemFontOfSize:14];
    
    week1 = [[UILabel alloc] init];
    week1.textColor = [UIColor colorWithRed:0.612  green:0.616  blue:0.616 alpha:1];
    week1.font = [UIFont systemFontOfSize:14];
    
    week2 = [[UILabel alloc] init];
    week2.textColor = [UIColor colorWithRed:0.612  green:0.616  blue:0.616 alpha:1];
    week2.font = [UIFont systemFontOfSize:14];
    
    week3 = [[UILabel alloc] init];
    week3.textColor = [UIColor colorWithRed:0.612  green:0.616  blue:0.616 alpha:1];
    week3.font = [UIFont systemFontOfSize:14];
    
    week4 = [[UILabel alloc] init];
    week4.textColor = [UIColor colorWithRed:0.612  green:0.616  blue:0.616 alpha:1];
    week4.font = [UIFont systemFontOfSize:14];
    
    week5 = [[UILabel alloc] init];
    week5.textColor = [UIColor colorWithRed:0.612  green:0.616  blue:0.616 alpha:1];
    week5.font = [UIFont systemFontOfSize:14];
    
    week6 = [[UILabel alloc] init];
    week6.textColor = [UIColor colorWithRed:0.612  green:0.616  blue:0.616 alpha:1];
    week6.font = [UIFont systemFontOfSize:14];
    
    
    line = [[UILabel alloc] initWithFrame:CGRectMake(0, 195 *hx, SCREEN_WIDTH, 3 *hx)];
    line.backgroundColor = [UIColor colorWithRed:0.552  green:0.592  blue:0.637 alpha:1];
    
    
    lab0.backgroundColor = [UIColor colorWithRed:0.255  green:0.428  blue:0.595 alpha:1];
    lab1.backgroundColor = [UIColor colorWithRed:0.255  green:0.428  blue:0.595 alpha:1];
    lab2.backgroundColor = [UIColor colorWithRed:0.255  green:0.428  blue:0.595 alpha:1];
    lab3.backgroundColor = [UIColor colorWithRed:0.255  green:0.428  blue:0.595 alpha:1];
    lab4.backgroundColor = [UIColor colorWithRed:0.255  green:0.428  blue:0.595 alpha:1];
    lab5.backgroundColor = [UIColor colorWithRed:0.255  green:0.428  blue:0.595 alpha:1];
    lab6.backgroundColor = [UIColor colorWithRed:0.255  green:0.428  blue:0.595 alpha:1];

    [self addSubview:time];
    [self addSubview:lab0];
    [self addSubview:lab1];
    [self addSubview:lab2];
    [self addSubview:lab3];
    [self addSubview:lab4];
    [self addSubview:lab5];
    [self addSubview:lab6];
    [self addSubview:line];
    [self addSubview:week0];
    [self addSubview:week1];
    [self addSubview:week2];
    [self addSubview:week3];
    [self addSubview:week4];
    [self addSubview:week5];
    [self addSubview:week6];

    week0.text = @"周一";
    week1.text = @"周二";
    week2.text = @"周三";
    week3.text = @"周四";
    week4.text = @"周五";
    week5.text = @"周六";
    week6.text = @"周天";


}

- (void)setDataArr:(NSArray *)dataArr
{
    _dataArr = dataArr;
    [self layoutViews];
}

- (void)setDate:(NSString *)date
{
    _date = date;
    time.text =date;

}

- (void)layoutViews
{
    [time mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.height.mas_equalTo(20);
        make.top.mas_equalTo(0);
        
    }];
    
    [lab0 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(59 *wx);
        make.width.mas_equalTo(25 *wx);
        make.height.mas_equalTo([self.dataArr[0] integerValue] *hx);
        make.bottom.mas_equalTo(line.mas_top);
    }];
    
    [lab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(lab0.mas_right).with.offset(20);
        make.width.and.bottom.equalTo(lab0);
        make.height.mas_equalTo([self.dataArr[1] integerValue] *hx);
    }];
    [lab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(lab1.mas_right).with.offset(20);
        make.width.and.bottom.equalTo(lab0);
        make.height.mas_equalTo([self.dataArr[2] integerValue] *hx);
    }];

    [lab3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(lab2.mas_right).with.offset(20);
        make.width.and.bottom.equalTo(lab0);
        make.height.mas_equalTo([self.dataArr[3] integerValue] *hx);
    }];

    [lab4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(lab3.mas_right).with.offset(20);
        make.width.and.bottom.equalTo(lab0);
        make.height.mas_equalTo([self.dataArr[4] integerValue] *hx);
    }];

    [lab5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(lab4.mas_right).with.offset(20);
        make.width.and.bottom.equalTo(lab0);
        make.height.mas_equalTo([self.dataArr[5] integerValue] *hx);
    }];

    [lab6 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(lab5.mas_right).with.offset(20);
        make.width.and.bottom.equalTo(lab0);
        make.height.mas_equalTo([self.dataArr[6] integerValue] *hx);
    }];
    
    [week0 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(lab0);
        make.top.mas_equalTo(line.mas_bottom);
        make.height.mas_equalTo(30);
        
    }];
    [week1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(lab1);
        make.top.mas_equalTo(line.mas_bottom);
        make.height.mas_equalTo(30);
        
    }];

    [week2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(lab2);
        make.top.mas_equalTo(line.mas_bottom);
        make.height.mas_equalTo(30);
        
    }];

    [week3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(lab3);
        make.top.mas_equalTo(line.mas_bottom);
        make.height.mas_equalTo(30);
        
    }];

    [week4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(lab4);
        make.top.mas_equalTo(line.mas_bottom);
        make.height.mas_equalTo(30);
        
    }];

    [week5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(lab5);
        make.top.mas_equalTo(line.mas_bottom);
        make.height.mas_equalTo(30);
        
    }];

    [week6 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(lab6);
        make.top.mas_equalTo(line.mas_bottom);
        make.height.mas_equalTo(30);
        
    }];


}
@end
















